package controlFlowGraph;

import java.math.BigInteger;
import java.util.HashSet;
import java.util.Set;

import domains.Interval;
import domains.IntervalBound;
import domains.IntervalDomain;

public class Constant extends Expression {
	
	private int constant;
	
	public Constant(int c) {
		this.constant = c;
	}
	
	public int getConstant() {
		return constant;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Constant) {
			Constant c = (Constant) obj;
			return c.getConstant() == this.constant;
		}
		return false;
	}

	@Override
	public int hashCode() {
		return constant;
	}

	@Override
	public String toString() {
		return Integer.toString(constant);
	}
	
	@Override
	public Set<Variable> getInvolvedVariables() {
		Set<Variable> res = new HashSet<Variable>();
		return res;
	}

	@Override
	public boolean isTrivial() {
		return true;
	}
	
	@Override
	public Interval abstractExpressionEvaluation(IntervalDomain dom){
		IntervalBound b = new IntervalBound(new BigInteger(Integer.toString(this.constant)),
				false,false);
		Interval res = new Interval(b,b);
		return res;
	}
	
}
